// index.js
const fs=wx.getFileSystemManager()

Page({
  data: {
    downfile:'',
    savefile:''
  },  
  downfile()
  {
    const that=this


    wx.downloadFile({
        url: 'https://res.wx.qq.com/wxdoc/dist/assets/img/0.4cb08bb4.jpg ',        
        success (res) {         
          if (res.statusCode === 200) {
            that.setData({
                downfile: res.tempFilePath
            }) 
            fs.getFileInfo({
                filePath:res.tempFilePath,
                digestAlgorithm:'md5',
                success (res) {  
                    console.log('文件大小',res.size)
                    console.log('文件摘要',res.digest)
                }
            })
            that.savefile(res.tempFilePath)
         }
        }     
      })   


  },
  savefile(tempfile)
  {
    const that=this
    fs.saveFile({
        tempFilePath:tempfile,
        success (res) {  
            console.log('临时路径',tempfile)
            console.log('存储后的路径',res.savedFilePath)    
            that.setData({
                savefile:res.savedFilePath
            })
            fs.getSavedFileInfo({
                filePath:res.savedFilePath,
                success (resinfo) { 
                    console.log('保存时间',resinfo.createTime)    
                    console.log('文件大小',resinfo.size)    
                }
            })
        }
    }) 
  },
  exportdisk()
  {
    const files=this.data.savefile   
    wx.saveFileToDisk({
        filePath:files ,
        success(res) {
          console.log('保存成功',res)
        }
      })
  }


})